<style>
    #expert-update {
        padding: 20px 25px 25px 0;
    }

    #expert-update .layui-treeSelect .ztree li a, .ztree li span {
        margin: 0 0 2px 3px !important;
    }

    #expert-update #data-permission-tree-block {
        border: 1px solid #eee;
        border-radius: 2px;
        padding: 3px 0;
    }

    #expert-update  .layui-treeSelect .ztree li span.button.switch {
        top: 1px;
        left: 3px;
    }

    .layui-layer-page .layui-layer-content {
        overflow: visible !important;
    }
</style>
<div class="layui-fluid" id="expert-update">
    <form class="layui-form" action="" lay-filter="expert-update-form">
        <div class="layui-form-item website-hide">
            <label class="layui-form-label website-form-item-require">专家id：</label>
            <div class="layui-input-block">
                <input type="text" name="expertId" data-th-value="${expert.expertId}">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md6">
                <label class="layui-form-label website-form-item-require">专家名：</label>
                <div class="layui-input-block">
                    <input type="text" name="name" minlength="2" maxlength="10" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <label class="layui-form-label website-form-item-require">学科分类：</label>
                <div class="layui-input-block">
                    <select name="subjectTypeCode" lay-verify="required">
                        <option value="">请选择</option>
                        <option
                                th:each="item : ${subjectTypeList}"
                                th:value="${item.code}" th:text="${item.name}">
                        </option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md6">
                <label class="layui-form-label website-form-item-require">所属单位：</label>
                <div class="layui-input-block">
                    <input type="text" name="company" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <label class="layui-form-label">固定电话：</label>
                <div class="layui-input-block">
                    <input type="tel" name="phone" lay-verify="tellphone" maxlength="50" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">证件类型：</label>
                    <div class="layui-input-block">
                        <select name="identityTypeCode" lay-filter="identityTypeCode" lay-verify="required" id="identityTypeCode">
                            <option value="">请选择</option>
                            <option
                                    th:each="item : ${zjlxList}"
                                    th:value="${item.code}" th:text="${item.name}">
                            </option>
                        </select>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">证件号：</label>
                    <div class="layui-input-block">
                        <input type="text" id="identityId" name="identityId" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label">银行帐号开户行：</label>
                    <div class="layui-input-block">
                        <input type="text" name="bankName" maxlength="80" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label">银行帐号：</label>
                    <div class="layui-input-block">
                        <input type="text" name="accountId" lay-verify="bank" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">理论与实务专家：</label>
                    <div class="layui-input-block">
                        <select name="featureTypeCode" lay-verify="required">
                            <option value="">请选择</option>
                            <option
                                    th:each="item : ${featureList}"
                                    th:value="${item.code}" th:text="${item.name}">
                            </option>
                        </select>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">京内与京外专家：</label>
                    <div class="layui-input-block">
                        <select name="districtTypeCode" lay-verify="required">
                            <option value="">请选择</option>
                            <option
                                    th:each="item : ${districtList}"
                                    th:value="${item.code}" th:text="${item.name}">
                            </option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">邮箱：</label>
                    <div class="layui-input-block">
                        <input type="text" name="email" lay-verify="required|email" maxlength="50" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">移动手机：</label>
                    <div class="layui-input-block">
                        <input type="text" name="mobile" lay-verify="required|phone" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label">通讯地址：</label>
                    <div class="layui-input-block">
                        <input type="text" name="address" maxlength="100" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">学术委员会成员：</label>
                    <div class="layui-input-block">
                        <select name="isMember" lay-verify="required">
                            <option value="">请选择</option>
                            <option value="0"> 否</option>
                            <option value="1"> 是</option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">职称：</label>
                    <div class="layui-input-block">
                        <input type="text" name="titleTypeCode" lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item website-hide">
            <button class="layui-btn" lay-submit="" lay-filter="expert-update-form-submit" id="submit"></button>
        </div>
    </form>
</div>

<script data-th-inline="javascript">
    layui.use(['website', 'form', 'formSelects', 'validate'], function () {
        var $ = layui.$,
            website = layui.website,
            layer = layui.layer,
            formSelects = layui.formSelects,
            form = layui.form,
            expert = [[${expert}]],
            $view = $('#expert-update'),
            validate = layui.validate;
        form.verify(validate);
        form.render();
        initExpertValue();
        formSelects.render();
        function initExpertValue() {
            form.val("expert-update-form", {
                "expertId": expert.expertId,
                "name": expert.name,
                "subjectTypeCode": expert.subjectTypeCode,
                "company": expert.company,
                "positionTypeCode": expert.positionTypeCode,
                "identityTypeCode": expert.identityTypeCode,
                "identityId": expert.identityId,
                "accountId": expert.accountId,
                "bankName": expert.bankName,
                "titleTypeCode": expert.titleTypeCode,
                "degreeTypeCode": expert.degreeTypeCode,
                "featureTypeCode": expert.featureTypeCode,
                "districtTypeCode": expert.districtTypeCode,
                "phone": expert.phone,
                "email": expert.email,
                "isMember": expert.isMember ? '1' : '0',
                "address": expert.address,
                "mobile": expert.mobile
            });
            var code=$('#identityTypeCode').val();
            if ("zjlx_sfz" === code) {
                $('#identityId')[0].setAttribute('lay-verify', "required|identityNumber")
            }else {
                $('#identityId')[0].setAttribute('lay-verify', "required")
            }
        }
        form.on('select(identityTypeCode)', function (data) {
            if ("zjlx_sfz" === data.value) {
                $('#identityId')[0].setAttribute('lay-verify', "required|identityNumber")
            }else {
                $('#identityId')[0].setAttribute('lay-verify', "required")
            }
        });
        form.on('submit(expert-update-form-submit)', function (data) {
            website.post(ctx + 'expert/update', data.field, function () {
                layer.closeAll();
                website.alert.success('数据修改成功');
                $('#website-expert').find('#query').click();
            });
            return false;
        });

    });
</script>